<?php
class LanguageAction extends BaseAction
{
    public function index()
    {
        $lang = I('get.lang');
        //dump($lang);
        $map['lang'] =$lang;
        $TagModel = D('Tag');
        $count = $TagModel->where($map)->count();
        $Page = parent::getPage($count);

        $items = $TagModel->join('vi_level ON vi_tag.lev = vi_level.itemid')
                          ->join('vi_course ON vi_tag.itemid = vi_course.itemid')
                          ->where($map)->where('lev=1')
                          ->limit($Page['limit'])
                          ->select ();

        $items1 = $TagModel->join('vi_level ON vi_tag.lev = vi_level.itemid')
            ->join('vi_course ON vi_tag.itemid = vi_course.itemid')
            ->where($map)->where('lev=2')
            ->limit($Page['limit'])
            ->select ();

        $items2 = $TagModel->join('vi_level ON vi_tag.lev = vi_level.itemid')
            ->join('vi_course ON vi_tag.itemid = vi_course.itemid')
            ->where($map)->where('lev=3')
            ->limit($Page['limit'])
            ->select ();

        if(count($items)==0 && count($items1)==0 && count($items2)==0){
            //echo "<script language='javascript'>alert('没有相关视频！');history.go(-1);</script>";
            echo "<script> alert('没有相关视频！');parent.location.href='/video'; </script>";
        }else{
        $this->assign('items', $items);
            $this->assign('items1', $items1);
            $this->assign('items2', $items2);
        $this->assign('page', $Page['page']);
        $this->display();
        }

    }
}